package com.practice.LocalDateTime和ZonedDateTime等java8中全新的时间API相关操作;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;

/**
 * @program: tenghw-practice-demo
 * @author: tenghw
 * @create: 2024-01-15 20:24
 * @Version 1.0
 * @description:
 **/
public class Demo5 {
    public static void main(String[] args) {
        //获取一个指定的时区
        ZoneId zoneId = ZoneId.of("Asia/Shanghai");

        LocalDateTime localDateTime0 = LocalDateTime.now();
        System.out.println(localDateTime0);

        //获取指定时区的当前时间
        LocalDateTime localDateTime = LocalDateTime.now(zoneId);
        System.out.println(localDateTime);

        // 获取带时区的时间和日期
        ZonedDateTime localDateTime2 = localDateTime.atZone(zoneId);
        System.out.println(localDateTime2);
    }

}